<?php require_once('Connections/dis01.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
  $MM_dupKeyRedirect="cad_nv_usu1003.php";
  $loginUsername = $_POST['nv_email'];
  $LoginRS__query = sprintf("SELECT nv_email FROM usu_novo WHERE nv_email=%s", GetSQLValueString($loginUsername, "text"));
  mysql_select_db($database_dis01, $dis01);
  $LoginRS=mysql_query($LoginRS__query, $dis01) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);

  //if there is a row in the database, the username was found - can not add the requested username
  if($loginFoundUser){
    $MM_qsChar = "?";
    //append the username to the redirect page
    if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
    $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
    header ("Location: $MM_dupKeyRedirect");
    exit;
  }
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
	$data1 = $_POST['nv_data'];
	$data1 = explode("/", $data1);
    $data1 = $data1[2]."-".$data1[1]."-".$data1[0];
  $insertSQL = sprintf("INSERT INTO usu_novo (nv_data, nv_nome, nv_email, nv_religiao) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($data1, "date"),
                       GetSQLValueString($_POST['nv_nome'], "text"),
                       GetSQLValueString($_POST['nv_email'], "text"),
                       GetSQLValueString($_POST['nv_religiao'], "text"));

  mysql_select_db($database_dis01, $dis01);
  $Result1 = mysql_query($insertSQL, $dis01) or die(mysql_error());

  $insertGoTo = "cad_nv_usu1003.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_dis01, $dis01);
$query_ls_versiculo = "SELECT verso_id, verso_descricao FROM versiculos ORDER BY verso_id DESC";
$ls_versiculo = mysql_query($query_ls_versiculo, $dis01) or die(mysql_error());
$row_ls_versiculo = mysql_fetch_assoc($ls_versiculo);
$totalRows_ls_versiculo = mysql_num_rows($ls_versiculo);
?>

<!DOCTYPE HTML5>
<html lang="pt-br">
<head>
<meta http-equiv="Content-Type" content="text/html; charset= UTF-8" />
<title>Disseminando.com</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" href="css/orman.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/nivo-slider.css" type="text/css" media="screen" />	

<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js">

</script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script type="text/javascript">

ddsmoothmenu.init({
	mainmenuid: "templatemo_menu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

</script>

<link rel="stylesheet" href="css/slimbox2.css" type="text/css" media="screen" /> 
<script type="text/JavaScript" src="js/slimbox2.js"></script> 

<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
</head>
<body id="subpage">

<div id="templatemo_wrapper">
	<div id="templatemo_header">
    	<div id="site_title"><img src="images/logo_projeto.png" width="296" height="76" /></div>
        <div id="templatemo_menu" class="ddsmoothmenu">
            <ul>
                <li><a href="index.php">Home</a></li>
                <li><a href="#" class="selected">Cadastro</a></li>
            </ul>
            <br style="clear: left" />
        </div> <!-- end of templatemo_menu -->
    </div> <!-- END of header -->
    
    <div id="templatemo_page_intro">
    	<h1>Versiculo do Dia</h1>
        <p><?php echo $row_ls_versiculo['verso_descricao']; ?></p>
    </div>
    
    
    <div id="templatemo_main">
    <div class="clear">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="images/blog/cad_banner01.png" width="616" height="200"></td>
        </tr>
        <tr>
          <td><p><strong>Amado(a) irmã(o) !!!</strong></p>
          <p><strong><em>É com muita alegria que  recebemos sua visita, queremos saber mais sobre você, cadastra-se !!!</em></strong></p></td>
        </tr>
      </table>
      <br>
      <br>
      <p>&nbsp;</p>
      <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
        <table width="509">
          <tr valign="baseline">
            <td width="91" nowrap>Data :</td>
            <td width="406"><input name="nv_data" type="text" value="<?php
                                                            $data1=date("d/m/Y");
                                                                  echo $data1;
                                                         ?>" size="12" readonly="readonly"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap>Nome :</td>
            <td><span id="sprytextfield1">
              <input name="nv_nome" type="text" value="" size="45" maxlength="255">
            <span class="textfieldRequiredMsg">Obrigatorio.</span></span></td>
          </tr>
          <tr valign="baseline">
            <td nowrap>Email :</td>
            <td><span id="sprytextfield2">
              <input name="nv_email" type="text" value="" size="45" maxlength="255">
            <span class="textfieldRequiredMsg">Obrigatorio.</span></span></td>
          </tr>
          <tr valign="baseline">
            <td nowrap>Igreja :</td>
            <td><span id="sprytextfield3">
              <input name="nv_religiao" type="text" value="" size="45" maxlength="100">
            <span class="textfieldRequiredMsg">Obrigatorio.</span></span></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">&nbsp;</td>
            <td><input type="submit" value="Cadastrar"></td>
          </tr>
        </table>
        <input type="hidden" name="MM_insert" value="form1">
      </form>
      <p>&nbsp;</p>
</div>       
        </div> <!-- END of content -->
        <div class="clear"></div>                
    </div> <!-- END of main -->
</div> <!-- END of wrapper -->

<div id="templatemo_bottom_wrapper">
	<div id="templatemo_bottom">
    	
        <div class="col col_3">
          <iframe frameborder="0" marginwidth="0" marginheight="0" scrolling="No" width="100%" height="30" style= "position: fixed; top: 0%; left: 0%;height: 6%;width: 100%;" src="http://streaming15.hstbr.net/player/radiogospeladoradores"></iframe>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div> <!-- END of bottom -->
    
</div> <!-- END of bottom wrapper -->

<div id="templatemo_footer_wrapper">
	<div id="templatemo_footer">
    	 <?php include('rodape.php') ?>
    </div> <!-- END of footer -->
</div> <!-- END of footer wrapper -->

<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
//-->
</script>
</body>
</html>
<?php
mysql_free_result($ls_versiculo);
?>
